import { createStore } from 'vuex'

const store = createStore({
    state: {
        PhotoList: [],
        Base64List: [],
        Name: [],
        class: { //牢记state中的属性也是ref类型的，而且computed计算属性要return结果，计算属性也可以进行修改
            value: { //watch的监听，也是监听响应式数据的变化，如果响应式数据发生改变，watch成功监听并更新监听的值
                category: '',
                time: '',
                fileName: ''
            }
        },
        UserName: [],
        UserNameId: ''
    },
    mutations: {
        sendPhotoList(state, arr) {
            console.log(arr)
            state.PhotoList = arr
            console.log(state.PhotoList)
        },
        sendBase64List(state, Arr) {
            // console.log(Arr)
            state.Base64List.value = Arr
                // 
                // console.log(state.Base64List)
                // console.log(state.Base64List.value)
        },
        sendName(state, Arr) {
            // console.log(Arr)
            state.Name = Arr
                // localStorage.setItem('keya', str)
            console.log(state.Name)
        },
        classify(state, object) {
            state.class.value = object
            console.log(object)
            console.log(state.class)
            console.log(state.class.value)

        },
        classifyCategory(state, str) {
            state.class.value.category = str
        },
        classifyTime(state, str) {
            console.log(str)
            state.class.value.time = str
        },
        classifyFileName(state, str) {
            state.class.value.fileName = str
        },
        SendUserName(state, Arr) {
            state.UserName = Arr
        },
        giveName(state, str) {
            state.UserNameId = str
        }
    },
    actions: {

    },
    getters: {

    }
})

export default store